package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

//使用对象输入流完成对象的反序列化操作
public class OISDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        File file = new File("person.obj");
//        file.createNewFile();

        //将person.obj文件中的对象返序列化
        FileInputStream fis = new FileInputStream("person.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        //         Object readObject()
        Person p = (Person) ois.readObject();
        System.out.println(p);

        ois.close();
    }
}
